package net.tatu.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.tatu.dao.EmailSendNoticeMapper;
import net.tatu.dao.MessageSendNoticeMapper;
import net.tatu.dao.PubCodeMapper;
import net.tatu.dao.SysLogMapper;
import net.tatu.dao.SysSendNoticeMapper;
import net.tatu.dao.UserMapper;
import net.tatu.model.EmailSendNotice;
import net.tatu.model.MessageSendNotice;
import net.tatu.model.PubCode;
import net.tatu.model.SysLog;
import net.tatu.model.SysSendNotice;
import net.tatu.model.User;
import net.tatu.service.PubCodeService;
import net.tatu.service.SendNoticeService;
import net.tatu.service.SysLogService;
import net.tatu.service.UserService;
import net.tatu.util.Encrypt;
import net.tatu.util.Util;

@Service
public class SendNoticeServiceImpl implements SendNoticeService {
	Logger log = Logger.getLogger(SendNoticeServiceImpl.class);
	@Autowired
	private MessageSendNoticeMapper messageSendNoticeMapper;
	@Autowired
	private SysSendNoticeMapper sysSendNoticeMapper;
	@Autowired
	private EmailSendNoticeMapper emailSendNoticeMapper;
	
	@Override
	public boolean createNotice(int sendNoticeTypeCode, long sendNoticeUserId) {
		log.debug("create notice");
		MessageSendNotice msn = new MessageSendNotice();
		SysSendNotice ssn = new SysSendNotice();
		EmailSendNotice esn = new EmailSendNotice();
		
		String notice = "用户id：" + sendNoticeUserId + " 提醒类型：" + sendNoticeTypeCode;
		msn.setSendNoticeStatusCode(10801);
		msn.setSendNoticeTypeCode(sendNoticeTypeCode);
		msn.setSendNoticeUserId(sendNoticeUserId);
		msn.setSendNoticeText(notice);
		msn.setRecordStatusCode(1);
		messageSendNoticeMapper.insertMessageSendNotice(msn);
		
		ssn.setSendNoticeStatusCode(10801);
		ssn.setSendNoticeTypeCode(sendNoticeTypeCode);
		ssn.setSendNoticeUserId(sendNoticeUserId);
		ssn.setSendNoticeText(notice);
		ssn.setRecordStatusCode(1);
		sysSendNoticeMapper.insertSysSendNotice(ssn);
		
		esn.setSendNoticeStatusCode(10801);
		esn.setSendNoticeTypeCode(sendNoticeTypeCode);
		esn.setSendNoticeUserId(sendNoticeUserId);
		esn.setSendNoticeText(notice);
		esn.setRecordStatusCode(1);
		emailSendNoticeMapper.insertEmailSendNotice(esn);
		return true;
	}
}
